package com.ezmobo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ezmobo.dao.AdminUser.AdminUserDO;
import com.ezmobo.dao.AdminUser.AdminUserMapper;

@Service
public class Test1 {
	@Autowired
	private AdminUserMapper dao;

	private int number = 0;

	@Transactional
	public void add(int id, String name) {
		System.out.println(number);

		AdminUserDO user = new AdminUserDO();
		user.setUser_id("2");
		user.setPassword("123456");
		dao.addAdminUser(user);

		user = new AdminUserDO();
		user.setUser_id("3");
		user.setPassword("123456");
		dao.addAdminUser(user);

		user = new AdminUserDO();
		user.setUser_id("4");
		user.setPassword("123456");
		dao.addAdminUser(user);

		// delete();

		number++;

	}

	@Transactional(propagation = Propagation.NESTED)
	public void delete() {
		System.out.println("delete1");
		dao.deleteUser("2");
		System.out.println("delete2");
		dao.deleteUser("3");
		System.out.println("delete3");
		int i = 0;
		int n = 10;
		int s = n / i;
	}

	public void add1() {
		AdminUserDO user = new AdminUserDO();
		user.setUser_id("2");
		user.setPassword("123456");
		dao.addAdminUser(user);

	}

	public void add2() {
		AdminUserDO user = new AdminUserDO();
		user.setUser_id("3");
		user.setPassword("123456");
		dao.addAdminUser(user);

	}
	
	public static void main(String[] args){
		Child c = new Child(1, "2");
	}

}
